<template>
  <div>
    <el-input v-model="content" style="width: 200px;margin-right: 20px"/>
    <el-button @click="addTodo" type="primary">增加toDo</el-button>

    <TodoList/>
  </div>
</template>

<script lang="ts">
import {defineComponent, ref} from "vue";

import TodoList from "@/components/TodoList.vue";
import {IUseTodo, useTodo} from "@/TodoPage/useTodo";


export default defineComponent({
  name: 'ToDoPage',
  components: {TodoList},
  setup() {
    const content = ref('')

    const viewModel: IUseTodo = useTodo()

    function addTodo() {
      viewModel.add(content.value, () => {
        content.value = ''
      })
    }


    return {
      content,
      addTodo,
    }
  }
});
</script>

<style scoped>

</style>
